import java.io.IOException;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;


/**
 * Servlet implementation class Controller
 */

public class Controller extends WebSocketServlet {
  private static final long serialVersionUID = 1L;
  private static String DELETE_JSP = "/Delete.jsp";
  private static String EDIT_JSP = "/Edit.jsp";
  private static String SHOWALL_JSP = "/ShowAll.jsp";

  
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String forward="";
    // Get a map of the request parameters
    @SuppressWarnings("unchecked")
    Map parameters = request.getParameterMap();
    if (parameters.containsKey("delete")){
      forward = DELETE_JSP;
    } else if (parameters.containsKey("edit")){
      forward = EDIT_JSP;
    } else {
      forward = SHOWALL_JSP;
    }
    System.out.println("");
    RequestDispatcher view = request.getRequestDispatcher(forward);
    view.forward(request, response);
  }


@Override
protected StreamInbound createWebSocketInbound(String arg0,
		HttpServletRequest arg1) {
	// TODO Auto-generated method stub
	return null;
}
} 